package com.linjiahao.serviceChat.controller;


import com.linjiahao.commonutils.JwtUtils;
import com.linjiahao.commonutils.ResultMap;
import com.linjiahao.serviceChat.entity.Chatmessage;
import com.linjiahao.serviceChat.service.ChatmessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author testjava
 * @since 2020-11-18
 */
@RestController
@RequestMapping("/serviceChat/chatmessage")
public class ChatmessageController {

    @Autowired
    ChatmessageService chatmessageService;

    @GetMapping("getMessage/{her_id}")
    public ResultMap getMessageById(@PathVariable String her_id, HttpServletRequest httpServletRequest){
        String Id= JwtUtils.getMemberIdByJwtToken(httpServletRequest);
        List<Chatmessage> message = chatmessageService.getMessage(her_id, Id);
        return ResultMap.ok().data("chatmessage",message);
    }

}

